﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
	CodeFile="ImportSIUI.aspx.cs" Inherits="ImportSIUI" Title="Untitled Page" %>

<%@ MasterType VirtualPath="~/MasterPage.master" %>
<%@ Register Namespace="NS_Controls" TagPrefix="cc1" %>
<%@ Register Namespace="CustomControlsNS" TagPrefix="cc2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderContent" runat="Server">
	<asp:UpdatePanel ID="upSIUI" runat="server">
		<ContentTemplate>
			<div id="divImportSIUI" runat="server" style="height: 100%; overflow: auto; display: block;">
				<table width="98%">
					<tr>
						<td>
							<div class="menu_th">
								<table>
									<tr>
										<td>
											<asp:Label ID="lblImportSIUI" runat="server" CssClass="menu_th1">Import SIUI</asp:Label>
										</td>
										<td>
											<asp:UpdateProgress ID="UpdateProgressImportSIUI" runat="server" DisplayAfter="100">
												<ProgressTemplate>
													<span id="spnProgress" class="clsTextBoldYellow">(<% =Resources.GridView.PageLoading %>)</span>
												</ProgressTemplate>
											</asp:UpdateProgress>
										</td>
									</tr>
								</table>
							</div>
							<table width="100%">
								<tr>
									<td style="width: 20%" class="tdn">
										Selectati fisierul:
									</td>
									<td id="tdUpload" runat="server" class="tdn" colspan="4">
										<asp:DropDownList ID="drpFiles" runat="server" Width="350px" />
									</td>
								</tr>
								<tr>
									<td style="width: 20%" class="tdn">
										Tip Import:
									</td>
									<td style="width: 30%" class="tdn">
										<span class="tdSmall">
											<asp:DropDownList ID="ddlImportType" runat="server" Width="350px" AutoPostBack="true"
												OnSelectedIndexChanged="ddlImportType_SelectedIndexChanged" />
										</span>
									</td>
									<td style="width: 20%" class="tdn">
										Cod Import:
									</td>
									<td style="width: 30%" class="tdn">
										<span class="tdSmall">
											<asp:DropDownList ID="ddl" runat="server" Width="350px" />
										</span>
									</td>
								</tr>
								<tr id="tr1" runat="server">
									<td style="width: 15%" class="tdn">
										<asp:Literal ID="ltrValidate" runat="server" Text="Cu validare:" />
									</td>
									<td style="width: 15%" class="tdn" colspan="3">
										<span class="tdSmall">
											<asp:CheckBox ID="chkValidation" runat="server" Checked="true" />
										</span>
									</td>
								</tr>
								<tr>
									<td class="tdn" colspan="4">
										<cc2:CustomButton ID="btnImport" runat="server" Text="Import SIUI" OnServerClick="btnImport_Click"
											OnClick="importStart();" />
									</td>
								</tr>
							</table>
							<div class="divEndTotal">
							</div>
						</td>
					</tr>
				</table>
			</div>
			<fieldset runat="server" id="fldGrid" style="padding: 2px 2px 2px 2px; width: 98%">
				<legend title="">Istoric Import:</legend>
				<div>
					<asp:GridView ID="GridView1" AllowPaging="True" BackColor="#f1f1f1" AutoGenerateColumns="false"
						DataKeyNames="ID" ShowFooter="true" Font-Size="Small" Font-Names="Verdana" runat="server"
						Width="50%" GridLines="None" BorderStyle="Outset" AllowSorting="true" OnPageIndexChanging="GridView1_PageIndexChanging"
						OnSorting="GridView1_Sorting" OnRowDataBound="GridView1_RowDataBound">
						<RowStyle BackColor="Gainsboro" />
						<AlternatingRowStyle BackColor="White" />
						<HeaderStyle BackColor="#0083C1" ForeColor="White" />
						<FooterStyle BackColor="White" />
						<Columns>
							<asp:TemplateField>
								<ItemTemplate>
									<a href="javascript:expandcollapse('div<%# Eval("ID") %>', 'one');">
										<img id="imgdiv<%# Eval("ID") %>" alt="Click to show/hide Orders for Customer <%# Eval("ID") %>"
											width="9px" border="0" src="../../Images/plus.gif" />
									</a>
								</ItemTemplate>
							</asp:TemplateField>
							<asp:TemplateField HeaderText="ID" SortExpression="ID">
								<ItemTemplate>
									<asp:Label ID="lblCustomerID" Text='<%# Eval("ID") %>' runat="server"></asp:Label>
								</ItemTemplate>
								<EditItemTemplate>
									<asp:Label ID="lblCustomerID" Text='<%# Eval("ID") %>' runat="server"></asp:Label>
								</EditItemTemplate>
							</asp:TemplateField>
							<asp:TemplateField HeaderText="UserName" SortExpression="UserName">
								<ItemTemplate>
									<%# Eval("UserName")%></ItemTemplate>
								<EditItemTemplate>
									<asp:TextBox ID="txtName" Text='<%# Eval("UserName") %>' runat="server"></asp:TextBox>
								</EditItemTemplate>
							</asp:TemplateField>
							<asp:TemplateField HeaderText="XML" SortExpression="XML">
								<ItemTemplate>
									<%# Eval("XML")%></ItemTemplate>
								<EditItemTemplate>
									<asp:TextBox ID="txtName" Text='<%# Eval("XML") %>' runat="server"></asp:TextBox>
								</EditItemTemplate>
							</asp:TemplateField>
							<asp:TemplateField HeaderText="DateImport" SortExpression="DateImport">
								<ItemTemplate>
									<%# Eval("DateImport")%></ItemTemplate>
								<EditItemTemplate>
									<asp:TextBox ID="txtName" Text='<%# Eval("DateImport") %>' runat="server"></asp:TextBox>
								</EditItemTemplate>
							</asp:TemplateField>
							<asp:TemplateField>
								<ItemTemplate>
									<tr>
										<td colspan="100%">
											<div id="div<%# Eval("ID") %>" style="display: none; position: relative; left: 15px;
												overflow: auto; width: 97%">
												<asp:GridView ID="GridView2" AllowPaging="True" BackColor="White" Width="80%" AutoGenerateColumns="false"
													Font-Names="Verdana" ShowFooter="true" Font-Size="X-Small" runat="server" GridLines="None"
													BorderStyle="Outset" AllowSorting="false" OnPageIndexChanging="GridView1_PageIndexChanging"
													OnSorting="GridView1_Sorting">
													<RowStyle BackColor="Gainsboro" />
													<AlternatingRowStyle BackColor="White" />
													<HeaderStyle BackColor="#0083C1" ForeColor="White" />
													<FooterStyle BackColor="White" />
													<Columns>
														<asp:TemplateField HeaderText="TablesImported" SortExpression="TablesImported">
															<ItemTemplate>
																<asp:Label ID="lblCustomerID" Text='<%# Eval("TablesImported") %>' runat="server"></asp:Label>
															</ItemTemplate>
															<EditItemTemplate>
																<asp:Label ID="lblCustomerID" Text='<%# Eval("TablesImported") %>' runat="server"></asp:Label>
															</EditItemTemplate>
														</asp:TemplateField>
													</Columns>
												</asp:GridView>
											</div>
										</td>
									</tr>
								</ItemTemplate>
							</asp:TemplateField>
						</Columns>
					</asp:GridView>
				</div>
			</fieldset>
            <asp:Label ID="lblMessage" runat="server" />
		</ContentTemplate>
	</asp:UpdatePanel>
	<ajaxToolKit:ModalPopupExtender ID="mdlPopup" runat="server" TargetControlID="pnlPopup"
		PopupControlID="pnlPopup" BackgroundCssClass="modalBackground" />
	<asp:Panel ID="pnlPopup" runat="server" CssClass="updateProgress" Style="display: none">
		<div align="center" style="margin-top: 13px;">
			<img src="../../Images/Hipocrate/rotator.gif" alt="" /><br />
			<span class="updateProgressMessage">Se genereaza importul ...</span><br />
			<span id="spanTimer"></span>
		</div>
	</asp:Panel>
	<script type="text/javascript">
		var g_str_mdlPopup = '<%=mdlPopup.ClientID %>';
		var g_str_spanTimer = 'spanTimer';

		var delayTimer = 1000;
		var timer = null;

		function importStart() {
			$find(g_str_mdlPopup).show();
			StartTheTimer();
		}

		function hideModal() {
			$find(g_str_mdlPopup).hide();
			StopTheTimer();
		}

		var startUpTime;
		function StartTheTimer() {
			startUpTime = new Date();
			spanTimer.innerHTML = '';
			timer = window.setInterval("getTime()", delayTimer);
		}

		function StopTheTimer() {
			clearTimeout(timer);
		}

		function getTime() {
			var spanTimer = $get(g_str_spanTimer);

			var time = new Date();
			var diff = (time.getHours() - startUpTime.getHours()) * 3600 + time.getMinutes() * 60 + time.getSeconds() - startUpTime.getMinutes() * 60 - startUpTime.getSeconds();
			var curr_sec = diff % 60;
			var curr_min = (diff - curr_sec) / 60;
			spanTimer.innerHTML = curr_min + " : " + (curr_sec < 10 ? '0' : '') + curr_sec;
		}

	</script>
</asp:Content>
